package com.situ.mall.web.service;

import com.mall.common.util.JsonResult;
import com.xzh.mallorderspi.model.OrderItem;
import com.xzh.mallorderspi.model.search.OrderSerachBean;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * 订单服务 Feign 客户端
 */
@FeignClient(name = "order-api", path = "/api/orders", contextId = "order-api")
public interface OrderFeignService {

    /**
     * 分页查询订单列表
     */
    @GetMapping
    ResponseEntity<JsonResult<?>> getOrderById(@RequestParam(defaultValue = "1", value = "pageNo") Integer pageNo,
                                               @RequestParam(defaultValue = "10", value = "pageSize") Integer pageSize,
                                               @ModelAttribute OrderSerachBean orders);

    /**
     * 更新订单状态
     */
    @PutMapping("/{orderId}/status")
    ResponseEntity<JsonResult<?>> updateOrderStatus(@PathVariable("orderId") Long orderId,
                                                   @RequestParam(value = "status") String status);

    /**
     * 取消订单
     */
    @PutMapping("/{id}/update")
    ResponseEntity<JsonResult<?>> cancelOrder(@PathVariable("id") Long orderId);

    /**
     * 支付订单
     */
    @PostMapping("/{orderId}/pay")
    ResponseEntity<JsonResult<?>> payOrder(@PathVariable("orderId") Long orderId,
                                          @RequestParam("paymentNo") String paymentNo);

    /**
     * 创建订单
     */
    @PostMapping("/create")
    ResponseEntity<JsonResult<?>> createOrder(@RequestBody OrderItem orderItem);

    /**
     * 查询用户订单列表
     */
    @GetMapping("/{userId}/status")
    ResponseEntity<JsonResult<?>> getUserOrders(@RequestParam(defaultValue = "1", value = "pageNo") Integer pageNo,
                                               @RequestParam(defaultValue = "10", value = "pageSize") Integer pageSize,
                                               @PathVariable("userId") Long userId,
                                               @RequestParam(value = "status") String status);

    /**
     * 获取销售关键指标
     */
    @GetMapping("/key-metrics")
    ResponseEntity<JsonResult<?>> getKeyMetrics(@RequestParam("startTime") java.time.LocalDate startTime,
                                               @RequestParam("endTime") java.time.LocalDate endTime);

    /**
     * 获取支付方式统计
     */
    @GetMapping("/pay-type")
    ResponseEntity<JsonResult<?>> getPayType(@RequestParam("startTime") java.time.LocalDate startTime,
                                            @RequestParam("endTime") java.time.LocalDate endTime);
} 